<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<title></title>
	</head>

	<body style="padding: 0;">
		<div id="toolbar" style="background: #F4F4F4;border-top:1px solid #95B8E7"></div>
		<div>
			<form id="ff">
				<table id="tt">

				</table>
			</form>
		</div>
		<div id="dlg" class="hiddenDialog">
			<iframe id="ifrmEdit" style="width: 100%;height: 100%;" frameborder="0" scrolling="no"></iframe>
		</div>
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/FrozenShareFunction/FrozenShare.js"></script>
	</body>
	<script type="text/javascript">
		var AddDialog;
		var searchCondition = "";
		var toolbar = [{
			"icon": "icon-warehousein",
			"func": "inStorage()",
			"functionname": "新建入库"
		}, {
			"icon": "icon-edit",
			"func": "edit()",
			"functionname": "编辑入库"
		}, {
			"icon": "icon-inventory_details",
			"func": "detail()",
			"functionname": "库存明细"
		}, {
			"icon": "icon-search",
			"func": "toSearchUI()",
			"functionname": "查询"
		}, {
			"icon": "icon-undo",
			"func": "redo()",
			"functionname": "查看所有数据"
		}];
		var receipts_type = "";
		var content = AddReceiptsToolBar(receipts_type, toolbar);
		$("#toolbar").append(content);
		GetDetailTable();
        
		//打开租赁页面弹出查询对话框
		//		toSearchUI();

		//库存明细
		function detail() {
			var row = $('#tt').datagrid('getSelected');
			if(!row) {
				$.messager.alert("消息", "请选中数据");
				return;
			} else {
				var pLocation = "";
				pLocation = "UI/FrozenCave/LeasingOperation/LeasingOperationDetail.html?ID=" + row.ID;
				AddTabIn("库存明细", parent.$("#tabs"), pLocation);
			}
		}

		//收费
		//		function charge() {
		//			var row = $('#tt').datagrid('getSelected');
		//			if(!row) {
		//				$.messager.alert("消息", "请选中数据");
		//				return;
		//			}
		//			var DialogWidth = 800;
		//			var DialogHeight = 330;
		//			var pLocation = "UI/FrozenCave/TenantCharge/TenantChargeAdd.html?type=in&id=" + row.ID + "&order_no=" + row.ORDER_NO;
		//			$("#ifrmEdit").attr("src", pLocation);
		//			constructDialog($("#dlg"), "收费", DialogWidth, DialogHeight);
		//			AddDialog.dialog('open');
		//		}

		//入库
		function inStorage() {
			toAddInDialog(-1);
		}

		//编辑
		function edit() {
			var row = $('#tt').datagrid('getSelected');
			if(!row) {
				$.messager.alert("消息", "请选中数据");
				return;
			}
			toAddInDialog(row.ID);
		}

		//查询
		function toSearchUI() {
			var DialogWidth = 400;
			var DialogHeight = 300;
			var pLocation = "UI/FrozenCave/LeasingOperation/LeasingOperationSearch.html";
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "查询", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		//关闭dialog
		function dialogClose() {
			AddDialog.dialog('close');
		}

		//构建datagrid
		function GetDetailTable() { //构造datagrid中的数据
			$('#tt').datagrid({
				//url: RemoteLinkAddress + "/frozen/inorder/list.do",
				height: 350,
				width: '100%',
				toolbar: '#toolbar',
				collapsible: true, //是否折叠：是
				singleSelect: true, //是否单选：是
				fitColumns: true, //自动调整列：是
				rownumbers: 'true',
				pagination: 'true',
				autoSave: true, //自动保存：是
				columns: [
					[{
							field: 'ID',
							title: 'ID',
							width: '0%',
							align: 'center',
						},
						{
							field: 'ORDER_NO',
							title: '编号',
							width: '10%',
							align: 'center',
						}, 
						{
							field: 'IN_DATE',
							title: '入库时间',
							width: '10%',
							align: 'center',
						}, 
						 {
							field: 'STOREHOUSE_NAME',
							title: '仓库名称',
							width: '8%',
							align: 'center',
						},{
							field: 'TENANT_NAME',
							title: '租户姓名',
							width: '8%',
							align: 'center',
						}, 
						{
							field: 'GOODS_NAME',
							title: '商品名称',
							width: '8%',
							align: 'center',
						}, 
						{
							field: 'SPEC',
							title: '规格',
							width: '10%',
							align: 'center',
						},{
							field: 'AMOUNT',
							title: '数量',
							width: '8%',
							align: 'center',
						},
						{
							field: 'CURR_AMOUNT',
							title: '剩余数量',
							width: '8%',
							align: 'center',
						},
//						{
//							field: 'ISCHARGE',
//							title: '入库收费',
//							width: '8%',
//							align: 'center',
//							formatter: function(value, row, index) {
//								return IsChargeState(value);
//							}
//						},
						{
							field: 'PARTNER1',
							title: '合伙人1',
							width: '8%',
							align: 'center',
						},
						{
							field: 'PARTNER2',
							title: '合伙人2',
							width: '8%',
							align: 'center',
						},{
							field: 'PARTNER3',
							title: '合伙人3',
							width: '8%',
							align: 'center',
						},
					]
				],
				onDblClickRow: function(index, row) {
					var pLocation = "";
					pLocation = "UI/FrozenCave/LeasingOperation/LeasingOperationDetail.html?ID=" + row.ID;
					AddTabIn("库存明细", parent.$("#tabs"), pLocation);
				}
			});
			$("#tt").datagrid("hideColumn", 'ID');
		}

		//弹出新增入库界面
		function toAddInDialog(_id) {
			var DialogWidth = 1200;
			var DialogHeight = 410;
			var pLocation = "UI/FrozenCave/LeasingOperation/LeasingOperationAddInStorage.html?id=" + _id;
			$("#ifrmEdit").attr("src", pLocation);
			constructDialog($("#dlg"), "入库", DialogWidth, DialogHeight);
			AddDialog.dialog('open');
		}

		function redo() {
			loadDatagridData("");
		}

		//查询界面调用，本页面加载数据
		function loadDatagridData(data) {
			searchCondition = data;
			var searchData = "";
			var _url = RemoteLinkAddress + "/frozen/inorder/list.do";
			searchData = "?" + data;
			if(data == "" || data == undefined) {
				searchData = "?CURR_AMOUNT=1";
			}
			$("#tt").datagrid('options').url = _url + searchData;
			$('#tt').datagrid('reload');
		}

		function reloadData() {
			loadDatagridData(searchCondition);
		}
	</script>

</html>